<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /* 
        思路：物品可以取任意个，因此是完全背包。问几种方式，因此是组合,外层物品内层背包
      */
      var change = function (amount, coins) {
        let dp = new Array(amount + 1).fill(0);
        let bagSize = amount;
        dp[0] = 1;
        for (let i = 0; i < coins.length; i++) {
          for (let j = coins[i]; j <= bagSize; j++) {
            dp[j] += dp[j - coins[i]];
          }
        }
        return dp[bagSize];
      };
    </script>
  </body>
</html>
